#include <iostream>
#include "BiGraph.h"
#include "AlgAstar.h"
#include <fstream>
#include <limits>
#include <cmath>
#include <vector>
#include <algorithm>
using std::pair;


using namespace std;

void read_file(int& start, int& end, BiGraph<int>& BGraph)
{
	
	ifstream in("in.txt", ifstream::in);
	if (!in.is_open()) 
	{ 
		cout<<"File Error"<<endl;
		system("pause");
		exit(1);
	}
	int n;
	in>>n;
	in>>start;
	in>>end;

	for (int i=0; i<n; i++)
	{
		for (int j=0; j<n; j++)
		{
			double weight;
			int v1, v2;
			in>>v1>>v2>>weight;
			BGraph.add_edge(v1, v2, weight);
			BGraph.add_edge(v2, v1, weight);

		}
	}
	in.close(); 
}


double evristic(BiGraph<int>::Vertex* current, BiGraph<int>::Vertex* end) {
	return 0;
}


int main()
{
	BiGraph<int> BGr;
    int start;
	int end;
	read_file(start, end, BGr);
	BiGraph<int>::Vertex* startVertex=BGr.find_or_create_vertex(start);
	BiGraph<int>::Vertex* endVertex=BGr.find_or_create_vertex(end);
	//astar(BGr, startVertex, endVertex, evristic);
	AlgStar<int> algstar=AlgStar<int>(evristic);
	vector<int> path = algstar.astar(BGr, startVertex, endVertex);
	if (path.empty()) {
		cout<<"No way"<<endl;
	} else {
		for(vector<int>::iterator itr=path.begin(); itr!=path.end(); itr++) {
				cout << *(itr) << " ";
		}
		cout<<endl;
	}
	//algAstar(BGr.find_or_create_vertex(start), BGr.find_or_create_vertex(end));
	system("pause");
	return 0;
}

